//
//  HomePageWillBeginOrderCell.m
//  YueYueSpecailCarDriver
//
//  Created by 李亚军 on 17/3/6.
//  Copyright © 2017年 黄旺鑫. All rights reserved.
//

#import "HomePageWillBeginOrderCell.h"
#import <QXDriverConfiguration/QXDriverConfiguration.h>
#import "HomePageAppointOrderWarningModel.h"

@implementation HomePageWillBeginOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    [self configureDefaultAttributes];
}

- (void)configureDefaultAttributes {
    
    self.backView.layer.cornerRadius = 5.0;
    self.backView.layer.masksToBounds = YES;

    self.timeImageView.image = [QXDriverConfiguration imageWithName:@"puclic_time_gray"];
    self.timeImageView.layer.cornerRadius = self.timeImageView.frame.size.height / 2.0;
    self.timeImageView.layer.masksToBounds = YES;
    
    self.departureAddress.layer.cornerRadius = self.departureAddress.frame.size.height / 2.0;
    self.departureAddress.layer.masksToBounds = YES;
    
    self.destinationAddress.layer.cornerRadius = self.destinationAddress.frame.size.height / 2.0;
    self.destinationAddress.layer.masksToBounds = YES;
}

- (void)setValueWithHomePageAppointOrderWarningModel:(HomePageAppointOrderWarningModel *)model {
    
    // 展示时间
    self.timeDescritionLabel.text = [NSString stringWithFormat:@"%@  %@" , @"即将开始" , [self getDateStringWithDateFormater:@"HH:mm" Interval:model.deparTime]];
    
    if (model.originAddress) {
        
        self.departureAddress.text = model.originAddress;
    }else {
        
        self.departureAddress.text = @"";
    }
    
    if (model.destAddress) {
        
        self.destinationAddress.text = model.destAddress;
    }else {
        
        self.destinationAddress.text = @"";
    }
    
}

/**
 根据时间戳返回指定格式的日期
 
 @param dateFomater 指定格式的日期格式
 @param interval 时间戳
 @return 返回的指定格式的时间戳
 */
- (NSString *)getDateStringWithDateFormater:(NSString *)dateFomater Interval:(NSTimeInterval)interval {
    
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval / 1000.0];
    NSDateFormatter *formater = [[NSDateFormatter alloc] init];
    [formater setDateFormat:dateFomater];
    return [formater stringFromDate:date];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
